<?php
$baseurl = current(split("index", $_SERVER['PHP_SELF']));
echo "<p class='banner' align='right' onmousedown='tekan(event);' onmousemove='gerak(event);' onmouseup='lepas();' onmouseout='lepas();'> <a href='Javascript:close_slip()'> <img src='".$baseurl."/img/no4.gif' alt='[ X ]'></a></p>";
echo "<hr color='#ccc'>";
echo "<div class='form'>";
echo "<h2> Appliying Job </h2>";
echo "<hr color='#2A7EF7'>";
    echo "<div class='kotak2'>"; 

    
    if($params == 'apply')
    {
        if( $jobseeker['jobseekers']['city_id']!=$job['jobs']['city_id'] || $jobseeker['resumes']['academic_id']<$job['jobs']['academic_id'] )
        {
            echo "<span class='red'>WARNING!!</span>";
            if( $jobseeker['jobseekers']['city_id']!=$job['jobs']['city_id'] )
            { echo "<br>:. <span class='info'>Your residence and the job's location are different</span>";  }
            if( $jobseeker['resumes']['academic_id']<$job['jobs']['academic_id'] )
            { echo "<br>:. <span class='info'>Your qualification level is not properly sufficient</span>";  }

        }

        echo $form->create('Applicant',array('action'=>'apply'));
        
            echo $this->element('myfunction');
            $complete = $this->requestAction(array('controller'=>'jobseekers','action'=>'complete_all')); 
            
            if($jobseeker['resumes']['upload_file']=='' && !$complete)
            { echo "<center><b><font style='color:red;font-size:120%;'>WARNING!!!</font><br> you haven't create neither your resume online or attachment resume</b></center>"; }
            
            echo "<div class='input'><label>To</label>  <input type='text' value='".$job['employers']['company_name']."' disabled=true size='30'></div>";
            echo "<div class='input'><label>Job's Position</label>  <input type='text' value='".$job['jobs']['position']."' disabled=true size='30'></div>";
		    
            echo "<div class='input'><label>Resume Attach</label>";  
            
            if($complete)
            { echo  "<input type='radio' id='status' name='data[Applicant][resume]' value='0' checked=true> Resume online<br>"; }
            else 
            { echo  "<input type='radio' id='status' name='data[Applicant][resume]' value='0' disabled='true'><font color='#aaa'> Resume online </font><br>"; } 
            
            if($jobseeker['resumes']['upload_file']!='')
            { 
                if($complete)
                { echo  "<label> &nbsp </label><input type='radio' id='status' name='data[Applicant][resume]' value='1' > Resume Attachment<br>"; }
                else
                { echo  "<label> &nbsp </label><input type='radio' id='status' name='data[Applicant][resume]' value='1' checked=true> Resume Attachment<br>"; }
            }
            else
            { echo  "<label> &nbsp </label><input type='radio' id='status' name='data[Applicant][resume]' value='1' disabled='true'><font color='#aaa'> Resume Attachment </font><br>"; }
            
            echo "</div>";
            echo $form->input('jobseeker_id',array('type'=>'hidden'));
		    echo $form->input('job_id',array('type'=>'hidden'));
            //echo $form->input('cover',array('type'=>'hidden'));
            
            echo "<input type='hidden' id='company_name' value='".$job['employers']['company_name']."'>";
            echo "<input type='hidden' id='position' value='".$job['jobs']['position']."'>";
            echo "<input type='hidden' id='created' value='".mydate($job['jobs']['created'])."'>";
            echo "<input type='hidden' id='now' value='".mydate(date("Y-m-d"))."'>";
            echo "<input type='hidden' id='first_name' value='".$jobseeker['jobseekers']['first_name']."'>";
            echo "<input type='hidden' id='last_name' value='".$jobseeker['jobseekers']['last_name']."'>";
            
            echo "<div class='input'><label> Cover Letter </label><input type='button' value='Load Example' onClick='gocover();'>";
            //echo "<br><label>&nbsp</label><textarea style='height:200px;width:280px;margin-top:10px;margin-bottom:10px' id='ApplicantCover' name='data[Applicant]['cover']'></textarea>";
            echo "</div>";
            echo $form->input('cover',array('label'=>'&nbsp'));
                echo "<div class='input'><label>&nbsp</label>";
                if($jobseeker['resumes']['upload_file']!='' || $complete)
                { echo "<input type='submit' value='Apply'"; }
                else
                { echo "<input type='submit' value='Apply' disabled='true'>"; }
            echo "</div>";
        echo "</form>";
    }    
    
    if($params == 'kembar')
    {
        echo "<span class='red'><center>You have applied this job, please re-check your applications</center></span>";
        echo "<br><center><a href='Javascript:close_slip()'>[ Close ]</a></center>";
    }
        
    if($params == 'invalid')
    {
        echo "<span class='red'>You have request an invalid link</span>";
        echo "<br><center><a href='Javascript:close_slip()'>[ Close ]</a></center>";
    }

    if($params == 'berhasil')
    {
        echo "<span class='red'>The applicationt has been sent, please wait for the confirmation</span>";
        echo "<br><center><a href='Javascript:close_slip()'>[ Close ]</a></center>";
    }
            
    echo "</div>";
echo "</div>";
?>
